package com.user_hosted_storage.entities;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Version;

/**
 * Entity implementation class for Entity: Client
 *
 */
@Entity
public class Client implements Serializable{

	
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	private long id;
	
	private String userName;
	
	private String passwordHash;
	
	private String ip;
	
	private int connectPort;
	
	private int acceptPort;
	
	private String email;
	
	private long maximumBitrate;
	
	private byte[] certificate;
	
	private byte[] keystore;
	
	private byte[] truststore;
	
	private boolean registeredJabber;
	
	@OneToMany(mappedBy="client")
	private Collection<CommunityMember> communitiesMember;
	
	@Version
    private Long version;

	
	public Client() {
		super();
	}

	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}

	public String getPasswordHash() {
		return passwordHash;
	}

	public void setPasswordHash(String passwordHash) {
		this.passwordHash = passwordHash;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public long getMaximumBitrate() {
		return maximumBitrate;
	}

	public void setMaximumBitrate(long maximumBitrate) {
		this.maximumBitrate = maximumBitrate;
	}

	public Collection<CommunityMember> getCommunitiesMember() {
		return communitiesMember;
	}

	public void setCommunitiesMember(Collection<CommunityMember> communitiesMember) {
		this.communitiesMember = communitiesMember;
	}
	
	public byte[] getCertificate() {
		return certificate;
	}
	
	public void setCertificate(byte[] certificate) {
		this.certificate = certificate;
	}

	public byte[] getKeystore() {
		return keystore;
	}

	public void setKeystore(byte[] keystore) {
		this.keystore = keystore;
	}

	public Long getVersion() {
		return version;
	}

	public void setVersion(Long version) {
		this.version = version;
	}

	public byte[] getTruststore() {
		return truststore;
	}

	public void setTruststore(byte[] truststore) {
		this.truststore = truststore;
	}
	
	public boolean isRegisteredJabber() {
		return registeredJabber;
	}
	
	public void setRegisteredJabber(boolean registeredJabber) {
		this.registeredJabber = registeredJabber;
	}
	
	public int getConnectPort() {
		return connectPort;
	}

	public void setConnectPort(int connectPort) {
		this.connectPort = connectPort;
	}

	public int getAcceptPort() {
		return acceptPort;
	}

	public void setAcceptPort(int acceptPort) {
		this.acceptPort = acceptPort;
	}

	@Override
	public boolean equals(Object obj) {
		if(!(obj instanceof Client) || obj == null) {
			return false;
		}
		
		Client client = (Client) obj;
		return client.id == id;
	}
	
	@Override
	public int hashCode() {
		return ((Long)id).hashCode();
	}
}
